import {
	createRouter,
	createWebHashHistory
} from "vue-router"
 
// 每个路由都需要映射到一个组件。
const routes = [  
  {
    path: "/",
    component: () => import("@/views/home/Home.vue"),
    name: "home",
    meta: {
      title: "首页",  
    }
  },
  {
    path: "/product",    //注意路由名、路径值 及对应的vue文件名
    component: () => import("@/views/product/ProductList.vue"),
    name: "product",
    meta: {
      title: "商品"
    },
  },  
  {
    path: "/productDetail",
    name:"productDetail",
    component: () => import('@/views/product/ProductDetail.vue'),   
    meta: {
      title: "商品详情"
    },
  }, 

  {
    path: "/user",
    component: () => import("@/views/user/User.vue"),
    name: "user",
    meta: {
      title: "我的"
    }
  }, 
	{
	    path: "/login",
	    component: () => import("@/views/user/Login.vue"),
	    name: "login",
	    meta: {
	      title: "登录"
	    }
	  },
		{    path: "/register",
		    component: () => import("@/views/user/Register.vue"),
		    name: "register",
		    meta: {
		      title: "用户注册"
		    }
		  },
			{    path: "/user/profile",
			    component: () => import("@/views/user/Profile.vue"),
			    name: "profile",
			    meta: {
			      title: "个人资料"
			    }
			  },
				{    
				    path: "/user/updatePwd",
				    component: () => import("@/views/user/UpdatePwd.vue"),
				    name: "updatePwd",
				    meta: {
				      title: "修改密码"
				    }
				  },
			{
					path: "/shopcart",
					name: "shopcart",
					component: () => import("@/views/shopcart/index.vue"),
					meta: {
						title: "购物车",
						requireAuth: true, //需要Token
					},
				},
				 {
				    path: "/order/create",
				    component: () => import("@/views/order/orderCreate.vue"),
				    name: "orderCreate",
				    meta: {
				      title: "新建订单",
				    },
				  },
					{    
					    path: "/address/addressList",
					    component: () => import("@/views/address/addressList.vue"),
					    name: "addressList",
					    meta: {
					      title: "收货地址列表",
					      requireAuth: true
					    }
					  },
						{
						    path: "/address/addressEdit",
						    component: () => import("@/views/address/AddressEdit.vue"),    
						    name: "addressEdit",
						    meta: {
						      title: "收货地址",
						      requireAuth: true
						    },
						  },
							{
							    path: "/order/list",
							    component: () => import("@/views/order/orderList.vue"),    
							    name: "orderList",
							    meta: {
							      title: "我的订单",
							      requireAuth: true
							    },
							},
							{
							    path: "/order/detail",
							    component: () => import("@/views/order/orderDetail.vue"),   
							    name: "orderDetail",
							    meta: {
							      title: "收订单详情",
							      requireAuth: true
							    },
							},

				{
				  path: "/working",
				  component: () => import("@/views/Working.vue"),
				  name: "working",
				  meta: {
				    title: "努力中...."
				  },
				},
				{
				  path: "/:pathMatch(.*)",
				  name:"notFound",
				  component: () => import('@/views/NotFound.vue'),
				  meta: {
				    title: "导航页面不存在"
				  },
				},
				

]
//  创建路由实例并传递 `routes` 配置
const router = createRouter({
	// 我们在这里使用 hash 模式。
	history: createWebHashHistory(),
	routes, // `routes: routes` 的缩写
})
export default router